package com.sdy.dcsb.web.util;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;

/**
 * @author Snaky
 * @date 2020/4/21 17:12
 */
public class FileUtil {

    /**
     * 将字符串保存至指定文件
     * @param content 文件内容
     * @param path 文件路径
     */
    public static File save(String content, String path) {
        File file = new File(path);
        try {
            if(!file.exists()){
                file.createNewFile();
            }
            BufferedOutputStream bout = new BufferedOutputStream(new FileOutputStream(file));
            bout.write(content.getBytes());
            bout.flush();
            bout.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return file ;
    }
}
